<template>
  <div class="account-setting">
    <div class="content">
      <div class="line" @click="jump('/rank')">
        <span class="label">排行榜</span>
        <div class="line-right">
          <img src="@/assets/image/right-icon.png" alt="" class="right-icon"/>
        </div>
      </div>
      <div class="line" @click="materialAuth('/materialAuth')" 
        v-if="role === 'HQ' || role === 'MERCHANT'">
        <span class="label">素材包授权</span>
        <div class="line-right">
          <!-- TODO 这个参数需要对接 -->
          <span class="gray-text">{{ detail.sum_auth }}人</span>
          <img src="@/assets/image/right-icon.png" alt="" class="right-icon"/>
        </div>
      </div>
      <div class="line" @click="jump('/teamsManageGeneral')">
        <div class="line-left">
          <span class="label">团队管理</span>
          <div class="badge" v-if="detail.has_wait_auth">待审核</div>
        </div>
        <div class="line-right">
          <span class="gray-text">{{ detail.sum_member }}人</span>
          <img src="@/assets/image/right-icon.png" alt="" class="right-icon"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getTeamInfo } from '@/api/selfuse'
export default {
  data () {
    return {
      detail: {}
    }
  },
  computed: {
    role() {
      return sessionStorage.getItem('role')
    }
  },
  mounted () {
    this.getDetail()
    document.title = '我的团队'
  },
  methods: {
    getDetail () {
      getTeamInfo().then(res => {
        this.detail = res
      })
    },
    jump (path) {
      this.$router.push({ path })
    },
    materialAuth () {
      // 根据当前的角色，跳转不同的页面
      const role = sessionStorage.getItem('role')
      if (role === 'HQ') {
        this.$router.push({ path: '/merchantList' })
      } else {
        this.$router.push({ 
          path: '/memberList',
          query: {
            merchant_id: sessionStorage.getItem('account_id')
          }
        })
      }
    }
  }
}
</script>

<style scoped>
.badge {
  width: 9.33vw;
  height: 4.27vw;
  line-height: 4.27vw;
  border-radius: 2.13vw;
  text-align: center;
  background: #E20000;
  font-family: Source Han Sans CN;
  font-size: 2.13vw;
  font-weight: 500;
  color: #FFFFFF;
}
.line-left {
  display: flex;
  align-items: center;
  height: 5.87vw;
}
.line-right {
  display: flex;
  align-items: center;
  height: 5.87vw;
}
.right-icon {
  width: 2vw;
  height: 2vw;
}
.account-setting {
  padding-top: 5.33vw;
}
.content {
  width: 89.6vw;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 2.13vw;
}
.line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 15.47vw;
  margin: 0 4vw;
  border-bottom: 1px solid #E6E6E6;
}
.line:last-of-type {
  border-bottom: none;
}
.label {
  margin-right: 1.33vw;
  font-family: Source Sans Pro;
  font-size: 3.73vw;
  font-weight: bold;
  color: #333333;
}
.red-text, .gray-text {
  margin-right: 2.13vw;
}
.red-text {
  font-family: Source Sans Pro;
  font-size: 3.2vw;
  font-weight: 600;
  color: #EA0000;
}
.gray-text {
  font-family: Source Han Sans CN;
  font-size: 3.2vw;
  font-weight: normal;
  color: #999999;
}
</style>